package homeWork_10_1;

import java.io.File;
import java.util.Arrays;

public class Exam1_1 {
    public static File[] listFiles(File file){
        if (!file.exists()){
            return null;
        }
        File[] fs = file.listFiles();
        if (fs.length==0){
            return null;
        }
        for (File f:fs){
            if (f.isFile()){
                f.delete();
            }else {
                File[] fs2 = listFiles(f);
                f.delete();
                if (fs2!=null){
                    int fsl = fs.length;
                    fs = Arrays.copyOf(fs,fs.length+fs2.length);
                    System.arraycopy(fs2,0,fs,fsl,fs2.length);
                }

            }
        }

        return fs;
    }

    public static void main(String[] args) {
        File f = new File("C:\\Users\\Tiangle\\Desktop\\111");
        File[] files = listFiles(f);
        for (File ff:files){
            System.out.println(ff.getPath());
        }
    }
}
